#ifndef FILE_LOG_BUF_H
#define FILE_LOG_BUF_H

#include <iostream>

class FileLogBuf : public std::streambuf 
{
public:
	FileLogBuf()
	{
		setp(buffer,buffer+Size);
	}

	virtual ~FileLogBuf()
	{
	}

	int sync ()
	{
		*(pptr()) = 0;
		setp(buffer, buffer+Size);
		return 0; 
	}

	int overflow(int c)
	{
		sync();
		if (c != EOF) 
		{
			*pptr() = static_cast<unsigned char>(c);
			pbump(1);
		}
		return 0;
	}

	// Defining xsputn is an optional optimization.
	// (streamsize was recently added to ANSI C++, not portable yet.)
	std::streamsize xsputn(const char *_Ptr, std::streamsize _Count)
	{
		return _Count;
	}

private:
	enum { Size=4095 }; 
	char buffer[Size+1];
};


#endif // 